/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package bab;

/**
 * Classe utilitaire pour Ub permet de socker des infos sur un objet
 * @author Luc DUZAN
 */
public class UbInfo implements Comparable<UbInfo>{
	private final int ido; //id of the object
	private final int profit;//valeur de l'object
	private final int weight;//poids de l'object
	private final double ratio;//ratio valeur/poid

	private EtatObject etat;

	/**
	 * 
	 * @param ido id de l'objet (son indice dans weights et profits de data)
	 * @param profit sa valeur
	 * @param weight son poids
	 */
	public UbInfo(int ido, int profit, int weight) {
		this.ido = ido;
		this.profit = profit;
		this.weight = weight;
		this.ratio = ((double)profit)/((double)weight);
		this.etat = EtatObject.FREE;
	}

	/**
	 * 
	 * @return id de l'objet (son indice dans weights et profits de data)
	 */
	public int getIdo() {
		return ido;
	}

	public int getProfit() {
		return profit;
	}

	public int getWeight() {
		return weight;
	}

	public double getRatio() {
		return ratio;
	}

	@Override
	/**
	 * Compare par rapport au ratio si ratio egal compare par valeur et si jamais egal compare par id
	 */
	public int compareTo(UbInfo o) {
		int result = ((Double)this.ratio).compareTo(o.ratio);

		if(result == 0) {
			result = ((Integer)this.profit).compareTo(o.profit);
		}

		if(result == 0) {
			result = ((Integer)this.ido).compareTo(o.ido);
		}

		return result;
	}

	public EtatObject getEtat() {
		return etat;
	}

	public void setEtat(EtatObject etat) {
		this.etat = etat;
	}

}
